<template>
<el-container class="container">
  <el-header class="header" :width="isCollapse ? '64px': '240px'">
       <div class="header-logo">
          <img src="../../assets/images/logo-normal.png" alt="">
       </div>
      <div class="toggle-button" @click="toggleClick">
          <i :class="[isCollapse?'el-icon-s-fold':'el-icon-s-unfold']"></i>
      </div>
      <el-button class="logout" type="primary" @click="logout" size="middle">退出</el-button>
      <!-- <avue-input v-model="form" placeholder="请输入内容" ></avue-input> -->
  </el-header>
  <el-container>
    <el-aside class="nav" :width="isCollapse ? '64px': '240px'">
      <el-menu default-active="this.$route.path" :router="true" class="el-menu-vertical-demo"  background-color="#20222a" text-color="#fff" active-text-color="#ffd04b" :collapse="isCollapse">
          <el-submenu v-for="item in menuList" :key="item.id" :index="item.id + ''">
            <!-- 一级菜单模板区 -->
            <template slot="title">
              <i :class="item.icon"></i>
              <span>{{ item.authName }}</span>
            </template>
            <!-- 二级菜单 -->
            <el-menu-item
              v-for="subItem in item.children"
              :key="subItem.id"
              :index="'/'+subItem.path"
               @click="saveNavState('/'+subItem.path)"
            >
              <template slot="title">
                <i class="el-icon-menu"></i>
                <span>{{subItem.authName}} </span>
              </template>
            </el-menu-item>
          </el-submenu>
      </el-menu>
      </el-aside>
      <el-main class="black">
        <router-view></router-view>
      </el-main>
    </el-container>
</el-container>
</template>
<script>
export default {
  name: 'Home',
  data() {
    return {
        form: '',
        isCollapse: false,
        menuList: [
          {
          id: '1', path:'/getway',authName:'网关管理',icon:"el-icon-s-home",
          children:[
             {id: '11',path:'/routing',authName:'路由管理'}
           ],
          }
        ]
    }
  },
  methods:{
     saveNavState(activePath) {
      this.activePath = activePath
    },
    logout() {},
    toggleClick() {
        this.isCollapse = !this.isCollapse;
    }
  }
}
</script>

<style lang="scss">
.container {
    height: 100vh;
    .header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        height: 64px;
        padding: 0;
        box-shadow: 0 1px 2px 0 gray;
        color: rgba(0,0,0,.65);
        .header-logo {
             float: left;
             width: 240px;
             height: 64px;
             background-color: #20222a;
             border-bottom: 1px solid #fff;
            img {
                width: 100%;
                height: 100%;
            }
        }
        .toggle-button {
            float: left;
            position: absolute;
            left: 270px;
            font-size: 26px;
        }
        .logout {
            margin-right: 20px;
        }
    }
    .nav {
        overflow-x: hidden;
        height: calc(100vh-60px);
        background-color: #20222a;
    }
    .el-submenu {
        text-align: left;
    }
}
.el-menu-vertical-demo:not(.el-menu--collapse) {
    width: 240px;
    min-height: 400px;
  }



</style>